package com.ossjk.oa.accounting.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ossjk.core.util.CommonMethod;
import com.ossjk.core.vo.PagePreNextVo;
import com.ossjk.oa.accounting.entity.CwCapitals;
import com.ossjk.oa.accounting.mapper.CwCapitalsMapper;
import com.ossjk.oa.accounting.service.ICwCapitalsService;
import com.ossjk.oa.accounting.vo.CwCapitalsVo;
import com.ossjk.oa.accounting.vo.StatisticsVo;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chair
 * @since 2020-05-14
 */
@Service
public class CwCapitalsServiceImpl extends ServiceImpl<CwCapitalsMapper, CwCapitals> implements ICwCapitalsService {

	@Override
	public Page selectVoPage(Page page, Wrapper wrapper) {
		// TODO Auto-generated method stub
		return null;
	}
	
	public PagePreNextVo selectPreOrNextByMth(String midMth ) {
		
		PagePreNextVo vo = new PagePreNextVo();
		
		vo.setPre(this.baseMapper.selectPreMth(midMth));
		vo.setNext(this.baseMapper.selectNextMth(midMth)); 
		vo.setCurrent(midMth);
		//取得6个月以前
 
		vo.setSelectAll( this.baseMapper.selectMax12Mth( CommonMethod.getxxMthBefore(midMth,-6)     ) );
	 
		return vo;
	}
	
    public int countByMth(String mth ) {
        return  baseMapper.countByMth(mth).intValue();
    }

	@Override
	public List<CwCapitalsVo> selectCapitalsByMth(String mth) {
		return baseMapper.selectAllByMth(mth);
	}

	@Override
	public List<CwCapitalsVo> selectCapitalsByTypeC(String typec) {
		return baseMapper.selectAllByTypeC(typec);
	}

	@Override
	public List<StatisticsVo> statistics(Integer type, String m1, String m2) {
		
       if(type == 1) {
    	   return baseMapper.statistics1(m1,m2);
       }else  if(type == 2) {
    	   return baseMapper.statistics2(m1);
       }else   {
    	   return baseMapper.statistics3(m1);
       }

	}
    
	
}
